#!/usr/bin/env python
# -*- coding: utf-8 -*-

from tornado.web import RequestHandler
import pymongo

def add(x, y):
    return x + y

class ClientStatPV(RequestHandler):
    def get(self): 
        """
        _time = self.get_argument('time', '').strip()
        if not _time:
            _time = '201110'
        connection = pymongo.Connection("10.103.13.15", 27017)
        db = connection.statictisnew
        collection = db[_time]
        posts = collection.find()
        
        _posts = []
        for post in posts:
            if  post.get('iphone2_0_pv') :
                _posts.append( post )
        
        self.render('templates/clientstatictis-pv.html', content=_posts, add=add)
        """
        self.write("123")
class ClientStatUV(RequestHandler):
    def get(self): 
        _time = self.get_argument('time', '').strip()
        if not _time:
            _time = '201110'
        connection = pymongo.Connection("10.103.13.15", 27017)
        db = connection.statictisnew
        collection = db[_time]
        posts = collection.find() 
        
        _posts = []
        for post in posts:
            _posts.append( post )
        
        self.render('templates/clientstatictis-uv.html', content=_posts, add=add)
        
class ClientStatWAP(RequestHandler):
    def get(self): 
        _time = self.get_argument('time', '').strip()
        if not _time:
            _time = '201110'
        connection = pymongo.Connection("10.103.13.15", 27017)
        db = connection.statictisnew
        collection = db[_time]
        posts = collection.find().sort('date', pymongo.ASCENDING)
        
        _posts = []
        for post in posts:
            _posts.append( post )
        
        self.render('templates/clientstatictis-wap.html', content=_posts)
